package presentationTier.actions;

import core.Movie;
import core.MovieException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import presentationTier.MainForm;
import presentationTier.MovieTableModel;
import presentationTier.dialogs.ChangeMovieDialog;

/**
 *
 * @author vojta
 */
public class ChangeMovieMenuItemAction implements ActionListener{

    MainForm form;

    public ChangeMovieMenuItemAction(MainForm aThis) {
        form = aThis;
    }

    public void actionPerformed(ActionEvent e) {
        try {
            MovieTableModel model = (MovieTableModel) form.jTable1.getModel();
            Movie movie = model.getMovieAt(form.jTable1.getSelectedRow());
            ChangeMovieDialog d = new ChangeMovieDialog(form, true, movie);
            d.setVisible(true);
        } catch (MovieException ex) {
            form.error(ex);
        }

    }

}
